package com.example.mobiletest.model

import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.json.Json

@Serializable
data class BookingData(
    val shipReference: String,
    val shipToken: String,
    val canIssueTicketChecking: Boolean,
    val expiryTime: String,
    val duration: Int,
    val segments: List<Segment>,
    @Transient
    var isCacheData: Boolean = false
) {
    companion object {
        fun decodeFromString(json: String): BookingData? {
            return try {
                Json.decodeFromString<BookingData>(json)
            } catch (e: Exception) {
                e.printStackTrace()
                null
            }
        }
    }
}

@Serializable
data class Segment(
    val id: Int,
    val originAndDestinationPair: OriginAndDestinationPair
)

@Serializable
data class OriginAndDestinationPair(
    val destination: Location,
    val destinationCity: String,
    val origin: Location,
    val originCity: String
)

@Serializable
data class Location(
    val code: String,
    val displayName: String,
    val url: String
)